home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 2 / Gold Medal Software Volume 2 (Gold Medal) (1994).iso / os2 / cenvi2.arj / EPM.CMD < prev    next >
OS/2 REXX Batch file  |  1993-06-14  |  2KB  |  61 lines

  1. EXTPROC CEnvi
  2. /************************************************************************
  3.  *** EPM.cmd - CEnvi program to start EPM with my favorite parameters ***
  4.  ***           and also by linking related .C, .H, or .CPP files if   ***
  5.  ***           any related file is an input parameter.                ***
  6.  ************************************************************************/
  7.  
  8. main(argc,argv)
  9. {
  10.    // all commands begin initially the same
  11.    EPMCommand = "start C:\\OS2\\APPS\\EPM.EXE /O /M /W"
  12.    IncludeFamily = FALSE  // assume family not included
  13.    if ( argc == 2  &&  !NameContainsWildcards(argv[1]) ) {
  14.       ext = SplitFileName(argv[1]).ext
  15.       if ( !stricmp(ext,".cpp")  ||  !stricmp(ext,".h")  ||  !stricmp(ext,".c") ) {
  16.          IncludeFamily = TRUE;
  17.          // build full name including .cpp, .h, and .c and include them all,
  18.          // but include the one that was entered first so it appears first
  19.          FileSpec = FullPath(argv[1])
  20.          if ( !AddFilespecIfFileExists(EPMCommand,FileSpec) )
  21.             AddFilespecsToCommand(EPMCommand,FileSpec)
  22.          NameParts = SplitFileName(FileSpec)
  23.          AddFilespecIfFileExists(EPMCommand,NameParts.dir,NameParts.name,".cpp")
  24.          AddFilespecIfFileExists(EPMCommand,NameParts.dir,NameParts.name,".h")
  25.          AddFilespecIfFileExists(EPMCommand,NameParts.dir,NameParts.name,".c")
  26.       }
  27.    }
  28.    if ( !IncludeFamily ) {
  29.       // any number of names was supplied, or just one name was supplied but it
  30.       // contained wildcards, and so simply open up with all of the names
  31.       for ( i = 1; i < argc; i++ )
  32.          AddFilespecsToCommand(EPMCommand,argv[i])
  33.    }
  34.    // EPMCommand has been build, and so finally execute it
  35.    system(EPMCommand)
  36. }
  37.  
  38. AddFilespecIfFileExists(Command,name1) // return TRUE if added, else FALSE
  39. {                                      // also fix case
  40.    // build full file spec
  41.    strcpy(fullspec,name1)
  42.    for ( i = 2; i < va_arg(); i++ )
  43.       strcat(fullspec,va_arg(i))
  44.    if ( NULL != (dirlist = Directory(fullspec)) ) {
  45.       AddFilespecsToCommand(Command,dirlist[0].name)
  46.       return TRUE
  47.    }
  48.    return FALSE
  49. }
  50.  
  51. AddFilespecsToCommand(Command,FileName)
  52. {
  53.    strcat(strcat(Command," "),FileName)
  54. }
  55.  
  56. NameContainsWildcards(Name) // return TRUE if contains wildcards, else FALSE
  57. {
  58.    return( NULL != strchr(Name,'*')  ||  NULL != strchr(Name,'?') )
  59. }
  60.  
  61.